﻿@using Achievement.Common;
@{
    ViewBag.Title = "成果库列表";
}
@section LayoutHeadContainer{
<link href="/css/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<link type="text/css" href="/css/mcdropdown/jquery.mcdropdown.css" rel="stylesheet" media="all" />
<script src="/scripts/facebox.js" type="text/javascript"></script>
<script type="text/javascript" src="/js/mcdropdown/jquery.mcdropdown.js"></script>
<script type="text/javascript" src="/js/mcdropdown/jquery.bgiframe.js"></script>
<script>
    $(function () {
        $(".btn").button();
    });
    function checkempty() {
        var result = true;
        $(".ckempty").each(function () {
            if ($(this).val() == "") {
                $(this).next("span").text(" 值不能为空！");
                result = false;
            }
            if (dd.getValue() == ",") {
                $(this).next("span").text(" 值不能为空！");
                result = false;
            }
        });
        return result;
    }
</script>
}
<!--Middle section-->
<div id="middle-sdo1">
  <div id="middle">
    <!--Message-->
    <div class="message">北京电力工程公司成果库系统欢迎您！</div>
    <!--Feature Box-->
    <table width="100%">
        <tr>
            <td style=" width:150px; vertical-align:middle"><span style=" padding-left:5px; padding-right:10px;">@Html.TextBox("txtSearch", "项目名称/关键词", new {maxlength="20", style = "color:#AAAAAA", value = "项目名称/关键词", onfocus = "if (value=='项目名称/关键词'){value ='';this.style.color='#000000'}", onblur = "if (value==''){value='项目名称/关键词';this.style.color='#AAAAAA'}" })</span></td>
            <td style=" width:170px; vertical-align:middle"><input type="text" name="searchfolder" id="searchfolder" value="" /></td>
            <td style=" width:120px">类型：@Html.DropDownList("ddlType","全部")</td>
            <td style=" width:100px"><button id="btnSearch" class="btn" onclick="gridReload();">搜索</button></td>
            <td style="text-align:right;padding-bottom:5px">
                @if(Achievement.Web.Common.UserInfo.ValidataRole(2)){
                <button id="uploadfile" class="btn" onclick="$.facebox({ ajax: '/Achievement/UploadFile'});">上传成果文件</button>
                }
                 @if (Achievement.Web.Common.UserInfo.ValidataRole(4))
                 {
                <button id="btnDownLoad" class="btn" onclick="BatchDownload()">批量下载</button>
                 }
            </td>
        </tr>
    </table>  
    <div class="clearfix"> </div>
    <div style="text-align:center"><table id="list2" style="margin:auto"></table></div>
        <div id="pager2"></div>
  </div>
</div>
<ul id="searchfoldermenu" class="mcdropdown_menu">
    <li rel="0">成果库</li>
    @Html.Raw(ViewData["ddlParent"].ToString())
</ul>
<script>
        $("#list2").jqGrid({
            url: '/Achievement/list?folder=@Request["FID"].SecureToLong()',
            datatype: "json",
            colNames: ['ID', '项目名称', '关键词', '参与人', '文件类型', '成果类型', '描述', '发表时间', '操作'],
            colModel: [
            { name: 'ID', index: 'ID', width: 55, classes: 'myjqgrid', hidden: true },
   		    { name: 'ProjectName', index: 'ProjectName', width: 100 },
   		    { name: 'KeyWord', index: 'KeyWord', width: 90 },
            { name: 'Participant', index: 'Participant', width: 90 },
            { name: 'Type', index: 'Type', width: 90 },
            { name: 'Folder', index: 'Folder', width: 90 },
            { name: 'Desc', index: 'Desc', width: 90, hidden: true },
            { name: 'CreateTime', index: 'CreateTime', width: 90 },
            { name: 'operate', index: 'operate', width: 150 , align:"center"},
   	    ],
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: '#pager2',
            sortname: 'ID',
            viewrecords: true,
            sortorder: "desc",
            caption: "成果列表",
            autowidth: true,
            shrinkToFit: true,
            multiselect: true,
            height: 'auto',
            emptyrecords: "暂无数据",
            editurl: "someurl.php",
            pgtext: '第{0}页 共{1}页',
            recordtext: '第 {0} - {1}条记录 '
        });
        jQuery("#list2").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: false,position:false },
        {
            addCaption: "添加",
            editCaption: "修改",
            bSubmit: "提交",
            bCancel: "取消",
            bClose: "关闭",
            saveData: "Data has been changed! Save changes?",
            bYes: "Yes",
            bNo: "No",
            bExit: "取消"
        }); 
        $("#bedata").click(function () {
            var gr = jQuery("#editgrid").jqGrid('getGridParam', 'selrow');
            if (gr != null) jQuery("#editgrid").jqGrid('editGridRow', gr, { height: 280, reloadAfterSubmit: false });
            else alert("Please Select Row");
        });
        $("#current_rev").html("v" + $.mcDropdown.version);
        $("#searchfolder").mcDropdown("#searchfoldermenu", {
            //select: TakeFolderValue,
            allowParentSelect: true,
            delim: "=>"
        });
        var dd = $("#searchfolder").mcDropdown();
        dd.setValue(@Request["FID"].SecureToLong());
        function gridReload(){
	        var nm_mask = jQuery("#item_nm").val();
	        var cd_mask = jQuery("#search_cd").val();
	        jQuery("#list2").jqGrid('setGridParam', { url: "/Achievement/list?folder=" + dd.getValue()[0] + "&type=" + $("#ddlType").val(),postData:{where:$("#txtSearch").val().replace('项目名称/关键词', '')}, page: 1 }).trigger("reloadGrid");
        }

        function OperatFunc(cellvalue, options, rowdata)
        {
            return "<a href=\"/Achievement/Download?ids=" + cellvalue + "\" target=\"_blank\">下载</a>" +
                    "&nbsp;&nbsp;<a href=\"/Achievement/View?id=" + cellvalue + "\">预览</a>" +
                    "&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"$.facebox({ ajax: '/Achievement/UploadFile?id=" + cellvalue + "'})\">修改</a>" +
                    "&nbsp;&nbsp;<a href=\"javascript:void(0)\" onclick=\"deleteacmt(" + cellvalue + ")\">删除</a>";
        }

        function deleteacmt(id) {
            if (confirm("删除操作不可逆，您确认删除吗？")) {
                window.location.href = "/Achievement/delete?id=" + id;
            }
        }

        function BatchDownload() {
            var ids = $("#list2").jqGrid('getGridParam', 'selarrrow');
            window.location.href = "/Achievement/Download?ids=" + ids;
        }

        function AchievementAuditing(id) {
        if (confirm("是否审核通过？")) {
            window.location.href = "/Achievement/AchievementAuditing?id=" + id;
        }
    }
</script>